import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextArea;


public class CalculatorPanel extends JPanel implements ActionListener{
	JPanel displayPanel;
	JPanel buttonPanel;
	JTextArea txtScreen;
	JButton btnMC;
	JButton btnMR;
	JButton btnMS;
	JButton btnMPlus;
	JButton btnMMinus;
	JButton btnBack;
	JButton btnCE;
	JButton btnC;
	JButton btnCPlusMinus;
	JButton btnSQRT;
	
	JButton btn0;
	JButton btn1;
	JButton btn2;
	JButton btn3;
	JButton btn4;
	JButton btn5;
	JButton btn6;
	JButton btn7;
	JButton btn8;
	JButton btn9;
	
	JButton btnMinus;
	JButton btnAdd;
	JButton btnMul;
	JButton btnDiv;
	JButton btnDivX;
	JButton btnPer;
	JButton btnDot;
	JButton btnEqual;
	CalculatorPanel()
	{
		setLayout(new BorderLayout());
		displayPanel = new JPanel();
		txtScreen = new JTextArea();
		displayPanel.add(txtScreen);
		buttonPanel = new JPanel(new GridBagLayout());
		add(displayPanel,BorderLayout.NORTH);
		add(buttonPanel,BorderLayout.CENTER);
		
		btnMC = new JButton("MC");
		btnMR = new JButton("MR");
		btnMS = new JButton("MS");
		btnMPlus = new JButton("M+");
		btnMMinus = new JButton("M-");
		btnBack =new JButton("<-");
		btnCE =new JButton("CE");
		btnC = new JButton("C");
		btnCPlusMinus = new JButton("+-");
		btnSQRT = new JButton("Sqrt");
		
		btn0 = new JButton("0");
		btn1 = new JButton("1");
		btn2 = new JButton("2");
		btn3 = new JButton("3");
		btn4 = new JButton("4");
		btn5 = new JButton("5");
		btn6 = new JButton("6");
		btn7 = new JButton("7");
		btn8 = new JButton("8");
		btn9 = new JButton("9");
		
		btnMinus = new JButton("+");
		btnAdd = new JButton("-");
		btnMul = new JButton("*");
		btnDiv = new JButton("/");
		btnDivX = new JButton("1/x");
		btnPer = new JButton("%");
		btnEqual = new JButton("=");
		btnDot = new JButton(".");
		GridBagConstraints c = new GridBagConstraints();
		
		
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 0;
		c.gridy = 0;
		buttonPanel.add(btnMC, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 1;
		c.gridy = 0;
		buttonPanel.add(btnMR, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 2;
		c.gridy = 0;
		buttonPanel.add(btnMS, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 3;
		c.gridy = 0;
		buttonPanel.add(btnMPlus, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 4;
		c.gridy = 0;
		buttonPanel.add(btnMMinus, c);
		
		//line 2
		// btnBack; btnCE; btnC; btnCPlusMinus; btnSQRT;
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 0;
		c.gridy = 1;
		buttonPanel.add(btnBack, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 1;
		c.gridy = 1;
		buttonPanel.add(btnCE, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 2;
		c.gridy = 1;
		buttonPanel.add(btnC, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 3;
		c.gridy = 1;
		buttonPanel.add(btnCPlusMinus, c);
		c.fill = GridBagConstraints.BOTH;
		c.weightx = 1;
		c.gridx = 4;
		c.gridy = 1;
		buttonPanel.add(btnSQRT, c);
		//line 3
		// btnBack; btnCE; btnC; btnCPlusMinus; btnSQRT;
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 0;
		c.gridy = 2;
		buttonPanel.add(btn7, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 1;
		c.gridy = 2;
		buttonPanel.add(btn8, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 2;
		c.gridy = 2;
		buttonPanel.add(btn9, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 3;
		c.gridy = 2;
		buttonPanel.add(btnDiv, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 4;
		c.gridy = 2;
		buttonPanel.add(btnPer, c);
		//line 4
		c.fill = GridBagConstraints.BOTH;
		c.weightx = 1;
		c.gridx = 0;
		c.gridy = 3;
		buttonPanel.add(btn4, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 1;
		c.gridy = 3;
		buttonPanel.add(btn5, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 2;
		c.gridy = 3;
		buttonPanel.add(btn6, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 3;
		c.gridy = 3;
		buttonPanel.add(btnMul, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 4;
		c.gridy = 3;
		buttonPanel.add(btnDivX, c);
		
		//line 5
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 0;
		c.gridy = 4;
		buttonPanel.add(btn1, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 1;
		c.gridy = 4;
		buttonPanel.add(btn2, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 2;
		c.gridy = 4;
		buttonPanel.add(btn3, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 3;
		c.gridy = 4;
		buttonPanel.add(btnMinus, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.weighty = 0.5;
		c.gridx = 4;
		c.gridy = 4;
		c.gridheight=2;
		buttonPanel.add(btnEqual, c);
		
		//line 6
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 2;
		//c.weighty = 0.5;
		c.gridx = 0;
		c.gridy = 5;
		c.gridwidth = 2;
		buttonPanel.add(btn0, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 2;
		c.gridwidth = 1;
		c.gridy = 5;
		buttonPanel.add(btnDot, c);
		c.fill = GridBagConstraints.BOTH;
		//c.weightx = 1;
		c.gridx = 3;
		c.gridy = 5;
		buttonPanel.add(btnAdd, c);
		
	}
	public void actionPerformed(ActionEvent evt)
	{
		
	}
}
